package org.wing.btn;

import com.tool.btn.MoBanBtn;
import com.tool.image.ImageMixDeal;
import com.tool.role.RoleData;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;

import java.awt.event.MouseEvent;
import java.math.BigDecimal;
import java.util.ArrayList;

import javax.swing.*;

import org.come.Frame.ZhuFrame;
import org.come.bean.SuitOperBean;
import org.come.entity.Goodstable;
import org.come.entity.PartJade;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.CutButtonImage;
import org.come.until.GoodsListFromServerUntil;
import org.come.until.GsonUtil;
import org.wing.mouseListener.WingUpStarMouseListener;
import org.wing.panel.WingMainPanel;



public class WingBtn extends MoBanBtn {

    /**
     * 1翅膀菜单按钮 2升级菜单按钮 3升星菜单按钮 4品质菜单按钮 5重铸菜单按钮 6炼化菜单按钮 10升级向左选择按钮 11升级向右选择按钮
     * 13品阶外观展示按钮 14物品培养按钮 15大话币培养按钮 16仙玉培养按钮 17召唤兽培养按钮 18培养按钮 19重铸按钮 20炼化按钮
     * 21向下翻页按钮 22向上翻页按钮
     */
    private int caozuo;
    private WingMainPanel wingMainPanel;
    /**翅膀主面板*/
    public WingBtn(String iconpath, int type,String text, int caozuo, WingMainPanel wingMainPanel) {
        super(iconpath, type);
        // TODO Auto-generated constructor stub
        this.caozuo = caozuo;
        this.wingMainPanel = wingMainPanel;
    }
    public WingBtn(String iconpath, int type, String text, int caozuo, WingMainPanel wingMainPanel,String sm) {
        super(iconpath, type, UIUtils.COLOR_BTNPUTONG);
        // TODO Auto-generated constructor stub
        this.caozuo = caozuo;
        this.wingMainPanel = wingMainPanel;
        this.setText(text);
        setFont(UIUtils.TEXT_HY16);
        setVerticalTextPosition(SwingConstants.CENTER);
        setHorizontalTextPosition(SwingConstants.CENTER);
    }

    @Override
    public void chooseyes() {
    }

    @Override
    public void chooseno() {
    }

    @Override
    public void nochoose(MouseEvent e) {
        // TODO Auto-generated method stub
        switch (caozuo) {
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
                this.changeMenu(this.caozuo);
            case 7:
            case 8:
            case 9:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
            case 17:
            default:
                break;
            case 10:
                this.leftBtnCaozuo();
                break;
            case 11:
                this.rightBtnCaozuo();
                break;
            case 18:
                // 升星操作
                if (wingMainPanel.getLeftType() == 3) {
                    upStarBtnCaozuo();
                } else if (wingMainPanel.getLeftType() == 2) {
                    upgradeBtnCaozuo();
                } else if (wingMainPanel.getLeftType() == 4) {
                    qualityBtnCaozuo();
                } else if (wingMainPanel.getLeftType() == 5) {
                    RecastBtnCaozuo();
                } else if (wingMainPanel.getLeftType() == 6) {
                    refiningBtnCaozuo();
                }
                break;
            case 19:
                this.RecastBtnCaozuo();
                break;
            case 20:
                this.refiningBtnCaozuo();
                break;
            case 21:
                if (this.wingMainPanel.getRightType() == 5) {
                    if (GoodsListFromServerUntil.getWingGoodsList().size() < this.wingMainPanel.getPageNumber() * 25) {
                        return;
                    }

                    this.wingMainPanel.setPageNumber(this.wingMainPanel.getPageNumber() + 1);
                } else if (this.wingMainPanel.getRightType() == 2) {
                    if (this.wingMainPanel.getPageNumber() >= GoodsListFromServerUntil.getGoodslist().length / 15 + 1) {
                        return;
                    }

                    this.wingMainPanel.setPageNumber(this.wingMainPanel.getPageNumber() + 1);
                }
                break;
            case 22:
                if (this.wingMainPanel.getPageNumber() <= 1) {
                    return;
                }

                this.wingMainPanel.setPageNumber(this.wingMainPanel.getPageNumber() - 1);
        }
    }

    // 切换菜单
    public void changeMenu(int type) {
        String style = MyIsif.getStyle();
        if ("水墨UI".equals(style)) {
        if (ImageMixDeal.userimg.getRoleShow().getBooth_id() != null) {
            ZhuFrame.getZhuJpanel().addPrompt2("摆摊状态不可以操作翅膀面板！");
            return;
        }
        try {
            switch (type) {
                case 1:
                    wingMainPanel.getWingMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K64.png"));
                    wingMainPanel.getUpgradeBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K65.png"));
                    wingMainPanel.getAmtyuranusBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K67.png"));
                    wingMainPanel.getQualityBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K69.png"));
                    wingMainPanel.getRecastMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K55.png"));
                    wingMainPanel.getRefineryMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K71.png"));
                    break;
                case 2:
                    wingMainPanel.getWingMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K63.png"));
                    wingMainPanel.getUpgradeBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K66.png"));
                    wingMainPanel.getAmtyuranusBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K67.png"));
                    wingMainPanel.getQualityBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K69.png"));
                    wingMainPanel.getRecastMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K55.png"));
                    wingMainPanel.getRefineryMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K71.png"));
                    break;
                case 3:
                    wingMainPanel.getWingMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K63.png"));
                    wingMainPanel.getUpgradeBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K65.png"));
                    wingMainPanel.getAmtyuranusBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K68.png"));
                    wingMainPanel.getQualityBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K69.png"));
                    wingMainPanel.getRecastMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K55.png"));
                    wingMainPanel.getRefineryMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K71.png"));
                    break;
                case 4:
                    wingMainPanel.getWingMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K63.png"));
                    wingMainPanel.getUpgradeBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K65.png"));
                    wingMainPanel.getAmtyuranusBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K67.png"));
                    wingMainPanel.getQualityBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K70.png"));
                    wingMainPanel.getRecastMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K55.png"));
                    wingMainPanel.getRefineryMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K71.png"));
                    break;
                case 5:
                    wingMainPanel.getWingMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K63.png"));
                    wingMainPanel.getUpgradeBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K65.png"));
                    wingMainPanel.getAmtyuranusBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K67.png"));
                    wingMainPanel.getQualityBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K69.png"));
                    wingMainPanel.getRecastMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K56.png"));
                    wingMainPanel.getRefineryMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K71.png"));
                    break;
                case 6:
                    wingMainPanel.getWingMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K63.png"));
                    wingMainPanel.getUpgradeBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K65.png"));
                    wingMainPanel.getAmtyuranusBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K67.png"));
                    wingMainPanel.getQualityBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K69.png"));
                    wingMainPanel.getRecastMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K55.png"));
                    wingMainPanel.getRefineryMenuBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K72.png"));
                    break;
                default:
                    break;
            }
            wingMainPanel.changLeftType(type);
        } catch (Exception e) {
            e.printStackTrace();
        }
        }else {
            if (ImageMixDeal.userimg.getRoleShow().getBooth_id() != null) {
                ZhuFrame.getZhuJpanel().addPrompt2("摆摊状态不可以操作翅膀面板！");
                return;
            }
            try {
                switch (type) {
                    case 1:
                        this.wingMainPanel.getWingMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_翅膀_选中_w80,h120.png"));
                        this.wingMainPanel.getUpgradeBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_升级_未选中_w80,h120.png"));
                        this.wingMainPanel.getAmtyuranusBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_升星_未选中_w80,h120.png"));
                        this.wingMainPanel.getQualityBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_品质_未选中_w80,h120.png"));
                        this.wingMainPanel.getRecastMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_重铸_未选中_w80,h120.png"));
                        this.wingMainPanel.getRefineryMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_炼化_未选中_w80,h120.png"));
                        break;
                    case 2:
                        this.wingMainPanel.getWingMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_翅膀_未选中_w80,h120.png"));
                        this.wingMainPanel.getUpgradeBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_升级_选中_w80,h120.png"));
                        this.wingMainPanel.getAmtyuranusBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_升星_未选中_w80,h120.png"));
                        this.wingMainPanel.getQualityBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_品质_未选中_w80,h120.png"));
                        this.wingMainPanel.getRecastMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_重铸_未选中_w80,h120.png"));
                        this.wingMainPanel.getRefineryMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_炼化_未选中_w80,h120.png"));
                        break;
                    case 3:
                        this.wingMainPanel.getWingMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_翅膀_未选中_w80,h120.png"));
                        this.wingMainPanel.getUpgradeBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_升级_未选中_w80,h120.png"));
                        this.wingMainPanel.getAmtyuranusBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_升星_选中_w80,h120.png"));
                        this.wingMainPanel.getQualityBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_品质_未选中_w80,h120.png"));
                        this.wingMainPanel.getRecastMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_重铸_未选中_w80,h120.png"));
                        this.wingMainPanel.getRefineryMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_炼化_未选中_w80,h120.png"));
                        break;
                    case 4:
                        this.wingMainPanel.getWingMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_翅膀_未选中_w80,h120.png"));
                        this.wingMainPanel.getUpgradeBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_升级_未选中_w80,h120.png"));
                        this.wingMainPanel.getAmtyuranusBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_升星_未选中_w80,h120.png"));
                        this.wingMainPanel.getQualityBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_品质_选中_w80,h120.png"));
                        this.wingMainPanel.getRecastMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_重铸_未选中_w80,h120.png"));
                        this.wingMainPanel.getRefineryMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_炼化_未选中_w80,h120.png"));
                        break;
                    case 5:
                        this.wingMainPanel.getWingMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_翅膀_未选中_w80,h120.png"));
                        this.wingMainPanel.getUpgradeBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_升级_未选中_w80,h120.png"));
                        this.wingMainPanel.getAmtyuranusBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_升星_未选中_w80,h120.png"));
                        this.wingMainPanel.getQualityBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_品质_未选中_w80,h120.png"));
                        this.wingMainPanel.getRecastMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_重铸_选中_w80,h120.png"));
                        this.wingMainPanel.getRefineryMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_炼化_未选中_w80,h120.png"));
                        break;
                    case 6:
                        this.wingMainPanel.getWingMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_翅膀_未选中_w80,h120.png"));
                        this.wingMainPanel.getUpgradeBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_升级_未选中_w80,h120.png"));
                        this.wingMainPanel.getAmtyuranusBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_升星_未选中_w80,h120.png"));
                        this.wingMainPanel.getQualityBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_品质_未选中_w80,h120.png"));
                        this.wingMainPanel.getRecastMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_重铸_未选中_w80,h120.png"));
                        this.wingMainPanel.getRefineryMenuBtn().setIcons(CutButtonImage.cuts("img/wing/一级选项卡_炼化_选中_w80,h120.png"));
                        break;
                }
                wingMainPanel.changLeftType(type);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    // 升星的培养按钮操作
    public void upStarBtnCaozuo() {

        if (wingMainPanel.getChosegoods() == null) {// 物品不存在
            return;
        }
        Goodstable goodstable = GoodsListFromServerUntil.getRgid(wingMainPanel.getWingGoods());
        if (goodstable == null) {
            return;
        }
        String[] split = goodstable.getValue().split("\\|");
        String goodsQuality = wingMainPanel.getGoodsValue(split, "品质");
        String qualityNumber = WingUpStarMouseListener.getGoodsQuality(goodsQuality);
        if (qualityNumber == null) {
            return;
        }
        if (wingMainPanel.getChosegoods().getUsetime() < Integer.parseInt(qualityNumber)) {
            // 数量不足
            ZhuFrame.getZhuJpanel().addPrompt2("物品数量不足");
            return;
        }
        Integer goodsValue = Integer.parseInt(wingMainPanel.getGoodsValue(split, "星级"));
        BigDecimal goodsTrue = WingUpStarMouseListener.getGoodsTrue(wingMainPanel.getChosegoods(), goodsValue);
        if (goodsTrue == null) {
            ZhuFrame.getZhuJpanel().addPrompt2("当前星级不可使用此秘石提升");
            return;
        }
        if (RoleData.getRoleData().getLoginResult().getGold().compareTo(goodsTrue) < 0) {
            // 金额不足
            ZhuFrame.getZhuJpanel().addPrompt2("大话币不足");
            return;
        }
        SuitOperBean operBean = new SuitOperBean();
        operBean.setType(32);
        operBean.setGoods(new ArrayList<BigDecimal>());

        operBean.getGoods().add(wingMainPanel.getWingGoods());
        for (int i = 0; i < Integer.parseInt(qualityNumber); i++) {
            operBean.getGoods().add(wingMainPanel.getChosegoods().getRgid());
        }
        deductGoods(wingMainPanel.getChosegoods(), Integer.parseInt(qualityNumber));
        String senmes = Agreement.suitOperateAgreement(GsonUtil.getGsonUtil().getgson().toJson(operBean));
        SendMessageUntil.toServer(senmes);
    }

    // 翅膀升级界面培养按钮
    public void upgradeBtnCaozuo() {
        if (this.wingMainPanel.getWingGoods() == null) {
            ZhuFrame.getZhuJpanel().addPrompt2("没有选择要升级的翅膀");
        } else {
            Goodstable goodstable = GoodsListFromServerUntil.getRgid(this.wingMainPanel.getWingGoods());
            if (goodstable != null) {
                int wingLevel = WingMainPanel.getWingLevel(this.wingMainPanel.getGoodsValue(goodstable.getValue().split("\\|"), "经验"));
                if (wingLevel >= 200) {
                    ZhuFrame.getZhuJpanel().addPrompt2("翅膀等级上限");
                } else if (this.wingMainPanel.getChosegoods() == null) {
                    ZhuFrame.getZhuJpanel().addPrompt2("没有要对应的物品");
                } else {
                    int parseInt = Integer.parseInt(this.wingMainPanel.getTextNumber().getText());
                    if (parseInt <= 0) {
                        ZhuFrame.getZhuJpanel().addPrompt2("请输入要培养的物品的数量");
                    } else if (this.wingMainPanel.getChosegoods().getUsetime() < parseInt) {
                        ZhuFrame.getZhuJpanel().addPrompt2("所选的物品数量不足");
                    } else if (RoleData.getRoleData().getLoginResult().getGold().compareTo(this.wingMainPanel.getMoney()) < 0) {
                        ZhuFrame.getZhuJpanel().addPrompt2("大话币不足");
                    } else {
                        SuitOperBean operBean = new SuitOperBean();
                        operBean.setType(31);
                        operBean.setGoods(new ArrayList());
                        operBean.getGoods().add(this.wingMainPanel.getWingGoods());
                        PartJade jade = new PartJade(this.wingMainPanel.getChosegoods().getRgid().intValue(), parseInt);
                        operBean.setJade(jade);
                        this.deductGoods(this.wingMainPanel.getChosegoods(), parseInt);
                        String senmes = Agreement.suitOperateAgreement(GsonUtil.getGsonUtil().getgson().toJson((Object)operBean));
                        SendMessageUntil.toServer(senmes);
                    }
                }
            }
        }
    }
    // 翅膀界面品质培养按钮操作
    public void qualityBtnCaozuo() {
        if (this.wingMainPanel.getWingGoods() == null) {
            ZhuFrame.getZhuJpanel().addPrompt2("没有选择要升级的翅膀");
        } else {
            Goodstable goodstable = GoodsListFromServerUntil.getRgid(this.wingMainPanel.getWingGoods());
            if (goodstable != null) {
                int parseInt = Integer.parseInt(this.wingMainPanel.getNumberLab().getText());
                if (parseInt <= 0) {
                    ZhuFrame.getZhuJpanel().addPrompt2("材料不能为0");
                } else {
                    Integer goodsValue = Integer.parseInt(this.wingMainPanel.getGoodsValue(goodstable.getValue().split("\\|"), "星级"));
                    if (goodsValue != 15) {
                        ZhuFrame.getZhuJpanel().addPrompt2("当前翅膀星级不足");
                    } else if (this.wingMainPanel.getChosegoods() == null) {
                        ZhuFrame.getZhuJpanel().addPrompt2("你没有当前升级品质的物品");
                    } else if (this.wingMainPanel.getChosegoods().getUsetime() < parseInt) {
                        ZhuFrame.getZhuJpanel().addPrompt2("物品数量不足");
                    } else if (RoleData.getRoleData().getLoginResult().getGold().compareTo(new BigDecimal(10000000)) < 0) {
                        ZhuFrame.getZhuJpanel().addPrompt2("大话币不足");
                    } else {
                        SuitOperBean operBean = new SuitOperBean();
                        operBean.setType(33);
                        operBean.setGoods(new ArrayList());
                        operBean.getGoods().add(this.wingMainPanel.getWingGoods());

                        for(int i = 0; i < parseInt; ++i) {
                            operBean.getGoods().add(this.wingMainPanel.getChosegoods().getRgid());
                        }

                        this.deductGoods(this.wingMainPanel.getChosegoods(), parseInt);
                        String senmes = Agreement.suitOperateAgreement(GsonUtil.getGsonUtil().getgson().toJson((Object)operBean));
                        SendMessageUntil.toServer(senmes);
                    }
                }
            }
        }
    }

    // 翅膀重铸按钮操作
    public void RecastBtnCaozuo() {
        if (wingMainPanel.getWingGoods() == null) {
            ZhuFrame.getZhuJpanel().addPrompt2("没有选择要重铸的翅膀");
            return;
        }
        if (wingMainPanel.getChosegoods() == null) {
            ZhuFrame.getZhuJpanel().addPrompt2("没有选择物品");
            return;
        }
        if (RoleData.getRoleData().getLoginResult().getGold().compareTo(wingMainPanel.getMoney()) < 0) {
            // 大话币不足
            ZhuFrame.getZhuJpanel().addPrompt2("大话币不足");
            return;
        }
        if (wingMainPanel.getChosegoods().getUsetime() <= 0) {
            ZhuFrame.getZhuJpanel().addPrompt2("重铸物品数量不足");
            return;
        }
        SuitOperBean operBean = new SuitOperBean();
        operBean.setType(34);
        operBean.setGoods(new ArrayList<BigDecimal>());
        operBean.getGoods().add(wingMainPanel.getWingGoods());
        // for (int i = 0; i < parseInt; i++) {
        operBean.getGoods().add(wingMainPanel.getChosegoods().getRgid());
        // }
        deductGoods(wingMainPanel.getChosegoods(), 1);
        String senmes = Agreement.suitOperateAgreement(GsonUtil.getGsonUtil().getgson().toJson(operBean));
        SendMessageUntil.toServer(senmes);
    }

    // 翅膀左侧向左按钮
    public void leftBtnCaozuo() {
        if (wingMainPanel.getWingGoods() == null) {
            ZhuFrame.getZhuJpanel().addPrompt2("没有选择要升级的翅膀");
            return;
        }
        if (wingMainPanel.getWingGoodsType() <= 0) {
            return;
        }
        if (wingMainPanel.getLeftType() == 1) {
            if (wingMainPanel.getWingGoodsType() / 25 + 1 != wingMainPanel.getPageNumber()) {
                wingMainPanel.setPageNumber(wingMainPanel.getWingGoodsType() / 25 + 1);
            }
            if (wingMainPanel.getWingGoodsType() % 25 == 0) {
                wingMainPanel.setPageNumber(wingMainPanel.getPageNumber() - 1);
            }
        }
        wingMainPanel.changeChooseWingGoods(GoodsListFromServerUntil.getWingGoodsList().get(wingMainPanel.getWingGoodsType() - 1),
                wingMainPanel.getWingGoodsType() - 1);

        // for (int i = 0; i <
        // GoodsListFromServerUntil.getWingGoodsList().size(); i++) {
        // if(GoodsListFromServerUntil.getWingGoodsList().get(i).getRgid().compareTo(wingMainPanel.getWingGoods().getRgid())
        // == 0){
        // if(i != 0 ){
        // wingMainPanel.changeChooseWingGoods(GoodsListFromServerUntil.getWingGoodsList().get(i-1));
        // return;
        // }
        // }
        // }
    }

    // 翅膀左侧向右按钮
    public void rightBtnCaozuo() {
        if (wingMainPanel.getWingGoods() == null) {
            ZhuFrame.getZhuJpanel().addPrompt2("没有选择要升级的翅膀");
            return;
        }
        if (wingMainPanel.getWingGoodsType() >= GoodsListFromServerUntil.getWingGoodsList().size() - 1) {
            return;
        }
        if (wingMainPanel.getLeftType() == 1) {
            if (wingMainPanel.getWingGoodsType() / 25 + 1 != wingMainPanel.getPageNumber()) {
                wingMainPanel.setPageNumber(wingMainPanel.getWingGoodsType() / 25 + 1);
            }
            if (wingMainPanel.getWingGoodsType() % 25 == 24) {
                wingMainPanel.setPageNumber(wingMainPanel.getPageNumber() + 1);
            }
        }
        wingMainPanel.changeChooseWingGoods(GoodsListFromServerUntil.getWingGoodsList().get(wingMainPanel.getWingGoodsType() + 1),
                wingMainPanel.getWingGoodsType() + 1);
        // for (int i = 0; i <
        // GoodsListFromServerUntil.getWingGoodsList().size(); i++) {
        // if(GoodsListFromServerUntil.getWingGoodsList().get(i).getRgid().compareTo(wingMainPanel.getWingGoods().getRgid())
        // == 0){
        // if(i != GoodsListFromServerUntil.getWingGoodsList().size() - 1 ){
        // wingMainPanel.changeChooseWingGoods(GoodsListFromServerUntil.getWingGoodsList().get(i+1));
        // return;
        // }
        // }
        // }
    }

    // 翅膀炼化界面炼化按钮操作
    public void refiningBtnCaozuo() {
        if (wingMainPanel.getChosegoods() == null) {
            // 物品未选中
            return;
        }
        if (wingMainPanel.getWingGoods() == null) {
            // 翅膀未选中
            ZhuFrame.getZhuJpanel().addPrompt2("没有选择要炼化的翅膀");
            return;
        }
        int parseInt = Integer.parseInt(wingMainPanel.getNumberLab().getText());
        if (wingMainPanel.getChosegoods().getUsetime() < parseInt) {
            // 物品数量不足
            ZhuFrame.getZhuJpanel().addPrompt2("物品数量不足");
            return;
        }
        if (RoleData.getRoleData().getLoginResult().getGold().compareTo(wingMainPanel.getMoney()) < 0) {
            // 资金不足
            ZhuFrame.getZhuJpanel().addPrompt2("大话币不足");
            return;
        }
        int getlock = wingMainPanel.getlock();
        int num = getlock % 10;
        if (num > 3) {
            // 超过了勾选数量
            ZhuFrame.getZhuJpanel().addPrompt2("勾选锁定只能3个");
            return;
        }
        int refiningMoney = wingMainPanel.getRefiningMoney(num);
        if (RoleData.getRoleData().getLoginResult().getCodecard().compareTo(new BigDecimal(refiningMoney)) < 0) {
            // 仙玉不足
            ZhuFrame.getZhuJpanel().addPrompt2("仙玉不足");
            return;
        }
        SuitOperBean operBean = new SuitOperBean();
        operBean.setType(35);
        operBean.setGoods(new ArrayList<BigDecimal>());
        operBean.getGoods().add(wingMainPanel.getWingGoods());
        operBean.setJade(new PartJade(getlock / 10, 0));
        for (int i = 0; i < parseInt; i++) {
            operBean.getGoods().add(wingMainPanel.getChosegoods().getRgid());
        }
        deductGoods(wingMainPanel.getChosegoods(), parseInt);
        String senmes = Agreement.suitOperateAgreement(GsonUtil.getGsonUtil().getgson().toJson(operBean));
        SendMessageUntil.toServer(senmes);
    }

    /** 物品消耗扣除 */
    public void deductGoods(Goodstable goodstable, int num) {
        goodstable.goodxh(num);
        if (goodstable.getUsetime() <= 0) {
            GoodsListFromServerUntil.Deletebiaoid(goodstable.getRgid());
        }
    }
}
